package team.umbc;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;

public class FriendsDB extends SQLiteOpenHelper {
	static final String DB_NAME = "friends.db";
	static final int DB_VERSION = 1;
	static final String TABLE = "friends";
	static final String F_ID = BaseColumns._ID;
	static final String F_NAME = "name"; 
	static final String F_FB_ID = "fb_id";
	static final String F_IMAGE = "photo";
	Context context;

	public FriendsDB(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
		this.context = context;
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		String sql = "create table " + TABLE + " (" +
				F_ID + " int primary key, " +
				F_FB_ID + " text, " +
				F_NAME + " text, " +
				F_IMAGE + " blob)";
		db.execSQL(sql);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		//eventually make it update when old < new but in development, we want to be able
		//to quickly change it and have the app initally roll out with V1.0
		//if (oldVersion != newVersion){
			db.execSQL("drop table if exists " + TABLE);
			onCreate(db);
		//}
	}
	
}